/*
 * Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gtugs.web.reporting;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jasonacooper@google.com (Jason Cooper)
 */
class SummaryEmail extends Email {

  private List<String> activeToInactive;
  private List<String> incubatingToActive;
  private List<String> incubatingEventRqmtsMet;

  public SummaryEmail() {
    activeToInactive = new ArrayList<String>();
    incubatingToActive = new ArrayList<String>();
    incubatingEventRqmtsMet = new ArrayList<String>();
  }

  public void addActiveToInactive(String chapter) {
    activeToInactive.add(chapter);
  }

  public void addIncubatingToActive(String chapter) {
    incubatingToActive.add(chapter);
  }

  public void addIncubatingEventRqmtsMet(String chapter) {
    incubatingEventRqmtsMet.add(chapter);
  }

  @Override
  public void send() {
    if (activeToInactive.size() > 0) {
      append("The following chaper(s) are listed as ACTIVE but have ");
      append("not met the minimum requirements to stay active:\n\n");

      for (String chapter : activeToInactive) {
        append("- ");
        append(chapter);
        append("\n");
      }

      append("\n");
    }
    if (incubatingToActive.size() > 0) {
      append("The following chapter(s) were listed as INCUBATING but ");
      append("met the minimum requirements to become active. Their ");
      append("status has been automatically upgraded:\n\n");

      for (String chapter : incubatingToActive) {
        append("- ");
        append(chapter);
        append("\n");
      }

      append("\n");
    }
    if (incubatingEventRqmtsMet.size() > 0) {
      append("The following chapter(s) are listed as INCUBATING. They ");
      append("have each met the event requirements to be listed as ");
      append("active, but other requirements have not been met.\n\n");

      for (String chapter : incubatingEventRqmtsMet) {
        append("- ");
        append(chapter);
        append("\n");
      }

      append("\n");
    }

    //if (activeToInactive.size() > 0 || incubatingToActive.size() > 0 ||
        //incubatingEventRqmtsMet.size() > 0) {
      super.send();
    //}
  }
}